<?php

include_once 'CodeObject.php';
include_once 'CodeNamespaceCollection.php';
include_once 'ImportCollection.php';

class CodeUnit extends CodeObject
{
    public function __construct(
        ImportCollection $Imports = null, CodeNamespaceCollection $Namespaces = null) 
    {
        is_null($Imports) ?
            $this->Imports = new ImportCollection() :
            $this->set_Imports($Imports);
        
        is_null($Namespaces) ?
            $this->Namespaces = new CodeNamespaceCollection() :
            $this->set_Namespaces($Namespaces);
    }
    
    public function __set($name, $value)
    {
        parent::__set($name, $value);
        
        if($name == 'Imports')
        {
            $this->set_Imports($value);
        }
        
        if($name == 'Namespaces')
        {
            $this->set_Namespaces($value);
        }
    }
    
    public function __get($name)
    {
        $ret = parent::__get($name);
        
        if($ret != null)
        {
            return $ret;
        }
        
        if($name == 'Imports')
        {
            return $this->get_Imports();
        }
        
        if($name == 'Namespaces')
        {
            return $this->get_Namespaces();
        }
    }
    
    public function get_Imports()
    {
        return $this->Imports;
    }

    public function set_Imports(ImportCollection $Imports)
    {
        $this->Imports = $Imports;
    }

    public function get_Namespaces()
    {
        return $this->Namespaces;
    }

    public function set_Namespaces(CodeNamespaceCollection $Namespaces)
    {
        $this->Namespaces = $Namespaces;
    }

    private $Imports;
    private $Namespaces;
}

?>
